<template>
  <h1>登录</h1>
  
  <hr/>

  <el-form
    :label-position="labelPosition"
    label-width="auto"
    :model="formLabelAlign"
    style="max-width: 600px"
  >

    
    <el-form-item label="Name" :label-position="itemLabelPosition">
      <el-input v-model="loginName" />
    </el-form-item>
    <el-form-item label="Password" :label-position="itemLabelPosition">
      <el-input v-model="loginPwd" type="password" />
    </el-form-item>
  </el-form>
  <el-button type="success" @click="dl()">登录</el-button>



  

</template>

<script lang='ts' setup>
import axios from '@/axios/index.js'
import { ref ,reactive} from 'vue'
import type { FormItemProps, FormProps } from 'element-plus'
import { useRoute,useRouter } from 'vue-router'
import useUserStore from '@/stores/userStore.js'
 
const labelPosition = ref<FormProps['labelPosition']>('right')
const itemLabelPosition = ref<FormItemProps['labelPosition']>('')

const formLabelAlign = reactive({
  name: '',
  region: '',
  type: '',
})

const store=useUserStore();

const router = useRouter()
const route = useRoute()
 let dl= async function() {
           let o =await axios.post("http://localhost:82/my/ajax/login"
            ,"loginName="+loginName.value+"&loginPwd="+loginPwd.value)
            // if(o.data.state==200){
              store.saveUser(o.data.date)
              // console.log('.....');
              sessionStorage.setItem("mc",JSON.stringify(o.data.date))
              router.push('/index')
              
            // }
     }

    const loginName=ref('')
     const       loginPwd=ref('')

   
  
    // data(){
    //     return{
            
    //         loginName:'',
    //         loginPwd:''
        
    //     }
    // },

    // methods:{
    //     dl:function(){
    //         axios.post("http://localhost:82/my/ajax/login"
    //         ,"loginName="+this.loginName+"&loginPwd="+this.loginPwd).then(function(res){
    //             alert(res.data.msg)
    //         })
    //     }
    // }
// }
</script>

<style>

</style>